package com.etnet.streamserver.view.common;

import com.etnet.streamserver.view.service.FieldInfo;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.dom4j.Element;

public class ViewFieldMapping {
    private static ViewFieldMapping fieldMapping = new ViewFieldMapping();

    private Map<String, FieldInfo> fieldmaps = new HashMap<String, FieldInfo>();

    public static ViewFieldMapping getInstance() {
        return fieldMapping;
    }

    public Map<String, FieldInfo> getFieldmaps() {
        return this.fieldmaps;
    }

    public void setFieldmaps(Map<String, FieldInfo> fieldmaps) {
        this.fieldmaps = fieldmaps;
    }

    public void loadData(Element element) {
        List<Element> list = element.elements();
        for (Element element2 : list) {
            String name = element2.attributeValue("name");
            String tip = element2.attributeValue("tip");
            String reqType = element2.attributeValue("reqType");
            String id = element2.attributeValue("code");
            String enable = element2.attributeValue("enable");
            String eng = element2.attributeValue("eng");
            String chi = element2.attributeValue("chi");
            String cht = element2.attributeValue("cht");
            FieldInfo fieldInfo = new FieldInfo();
            fieldInfo.setEnable(false);
            if (enable.equalsIgnoreCase("true")) {
                fieldInfo.setEnable(true);
            }
            fieldInfo.setId(id);
            fieldInfo.setName(name);
            fieldInfo.setTip(tip);
            fieldInfo.setReqType(reqType);
            fieldInfo.setChi(chi);
            fieldInfo.setCht(cht);
            fieldInfo.setEng(eng);

            this.fieldmaps.put(id, fieldInfo);
        }
    }
}